import { api, ApiResponse } from './index';

export interface StoryItem {
    id: number;
    name: string;
    title: string;
    categoryId: number;
    content: string;
    views: number;
    collects: number;
    thumbnail: string;
    ttsUrl: string;
    createTime: string;
}

export interface UserCollect {
    detailId: number;
    userId: number;
}

export const findTop6Views = () => {
    return api.post<ApiResponse<StoryItem[]>>('/v1/fairy/findTop6Views');
};

export const findTop6Collects = () => {
    return api.post<ApiResponse<StoryItem[]>>('/v1/fairy/findTop6Collects');
};

export const GetStoryDetail = (id: number) => {
    return api.post<ApiResponse<StoryItem>>('/v1/fairy/detail', { id });
};

export const toggleCollect = (userCollect: UserCollect) => {
    return api.post<ApiResponse<void>>('/v1/fairy/toggleCollect', userCollect);
}